#@adminLayout()
#define main()
#set(map={C:1,R:1,U:1,D:1,O:1},aTh=["用户名","姓名","手机号码","性别","邮箱","头像","注册时间","是否锁定"],
aTd=["userName","fullName","mobile","sex","email","avatar","createAt","status"])
<div class="card">
    #@cardIndex("账户管理","sys/account",map,aTh,aTd)
</div>
<script type="text/javascript">
    $(document).ready(function () {
        initSwitchInput(prepareAction);
    });

    function prepareAction($this, state) {
        return {
            url: state ? "/admin/sys/account/lock" : "/admin/sys/account/unlock",
            data: {
                id: $this.attr("data-id")
            }
        }
    }

</script>
#end


#define cardQuery()

<div class="col-sm-4">
    <div class="form-group">
        <lable><i class="zmdi zmdi-label-alt zmdi-hc-fw"></i>用户名</lable>
        <input type="text" name="userName" value="#(model.userName??)"
               class="form-control" placeholder="请输入用户名">
        <i class="form-group__bar"></i>
    </div>
</div>
<div class="col-sm-4">
    <label><i class="zmdi zmdi-label-alt zmdi-hc-fw"></i>注册时间</label>
    <div class="input-group">
        <span class="input-group-addon"><i class="zmdi zmdi-calendar"></i></span>
        <div class="form-group">
            <input type="text" class="form-control date-picker" name="createAt" value="#(model.createAt??)"
                   placeholder="请选择注册时间">
            <i class="form-group__bar"></i>
        </div>
    </div>
</div>
#end
#define cardIndexTbody()
<td data-column="sex">
        #if(x.sex==0)
        男
        #else if(x.sex==1)
        女
        #else
        性别不详
        #end
</td>
<td data-column="avatar">
    <img src="/upload/avatar/#(x.avatar?? == '' ? 'x.jpg' :x.avatar)" style="height: 30px;width: 30px;">
</td>
<td data-column="status"><div>
    #if(x.status==0)
        注册、未激活
    #else if(x.status==1)
        正常、已激活
    #else
        账户已锁定
    #end</div>
</td>
#end

#define cardIndexBtn()
#if(x.status == 1)
#permission("/admin/sys/account/assignRoles")
<a data-pjax class="btn btn-sm btn-outline-info waves-effect"
   href="/admin/sys/account/assignRoles?id=#(x.id)&p=#(page.pageNumber)&s=#(page.pageSize)"
   title="分配角色">
    <i class="zmdi zmdi-account"></i>
</a>
#end
#end
#end